
  class ListNode {
     int val;
     ListNode next;
     ListNode() {}
     ListNode(int val) { this.val = val; }
     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 }

class Solution {
    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        ListNode phead=new ListNode();
        ListNode tail=phead;
        ListNode cur1=l1;
        ListNode cur2=l2;
        int k=0;


        while(cur1!=null&&cur2!=null){
            int n=0;
            if(k>0) n=k;
            n+=cur1.val+cur2.val;
            ListNode newNode=new ListNode(n%10);
            tail.next=newNode;
            tail=newNode;
            k=n/10;
            cur1=cur1.next;
            cur2=cur2.next;

        }

        while(cur1!=null){

            int n=cur1.val+k;
            ListNode newNode=new ListNode(n%10);
            tail.next=newNode;
            tail=newNode;
            cur1=cur1.next;
            k=n/10;

        }

        while(cur2!=null){
            int n=cur2.val+k;
            ListNode newNode=new ListNode(n%10);
            tail.next=newNode;
            tail=newNode;
            k=n/10;
            cur2=cur2.next;

        }

        if(k>0){
            ListNode newNode=new ListNode(k);
            tail.next=newNode;
        }

        return phead.next;


    }

    public static void main(String[] args) {
        System.out.println((int)'a');
    }
}

/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution1 {
    public ListNode swapPairs(ListNode head) {

        if(head==null||head.next==null) return head;

        ListNode next=head.next;
        ListNode nnext=next.next;
        next.next=head;
        head.next= swapPairs(nnext);
        return next;

    }
}